<!DOCTYPE html>
<html>
<head>
    <title>Charge Distribution Diagram</title>
</head>
<body>
<canvas id="physicsCanvas" width="600" height="200"></canvas>
<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // Parameters for drawing
    const centerY = 100;
    const radius = 30;
    const spacing = 120;
    const numCharges = 4;
    const startX = (canvas.width - (numCharges - 1) * spacing) / 2;

    // Style settings
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;
    ctx.textAlign = 'center';
    
    // Set a font that resembles the handwritten style in the image
    const labelFont = 'italic 30px "Times New Roman"';
    const symbolFont = '30px "Times New Roman"';

    // Function to draw a charge
    function drawCharge(x, y, r, isPositive) {
        // Draw circle
        ctx.beginPath();
        ctx.arc(x, y, r, 0, 2 * Math.PI);
        ctx.stroke();

        // Draw sign (+ or -)
        ctx.font = symbolFont;
        ctx.textBaseline = 'middle';
        if (isPositive) {
            ctx.fillText('+', x, y + 2); // + symbol is often slightly above vertical center
        } else {
            ctx.fillText('-', x, y);
        }

        // Draw charge label (e or -e)
        ctx.font = labelFont;
        ctx.textBaseline = 'top';
        const chargeText = isPositive ? 'e' : '−e'; // Using a proper minus sign
        ctx.fillText(chargeText, x, y + r + 10);
    }

    // Draw the sequence of charges
    for (let i = 0; i < numCharges; i++) {
        const x = startX + i * spacing;
        const isPositive = i % 2 === 0;
        drawCharge(x, centerY, radius, isPositive);
    }

    // Draw the spacing labels 'a'
    ctx.font = labelFont;
    ctx.textBaseline = 'bottom';
    for (let i = 0; i < numCharges - 1; i++) {
        const x = startX + i * spacing + spacing / 2;
        ctx.fillText('a', x, centerY - radius - 5);
    }

    // Draw the ellipses (...) to indicate infinite chain
    ctx.font = 'bold 30px "Times New Roman"';
    ctx.textBaseline = 'middle';
    const ellipsisY = centerY;
    
    // Left ellipsis
    const leftEllipsisX = startX - spacing * 0.6;
    ctx.fillText('...', leftEllipsisX, ellipsisY);

    // Right ellipsis
    const rightEllipsisX = startX + (numCharges - 1) * spacing + spacing * 0.6;
    ctx.fillText('...', rightEllipsisX, ellipsisY);

</script>
</body>
</html>